package br.com.sgs.util;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.hibernate.Session;


public class UtilHibernate {

        private static EntityManager em;
        private static EntityManagerFactory emf = Persistence.createEntityManagerFactory("JPA-Eric");
	
	public static Session getConection(){
	
            em = Persistence.createEntityManagerFactory("JPA-Eric").createEntityManager();
		
		return (Session)em.getDelegate();
		
	}
        
       public static void close(){
		
		em.close();
		
		
	}
       
       public static EntityManager getEM(){
           
            em = emf.createEntityManager();
            return em;
           
       } 
       
}
